package com.youbug.mall.product_pms.service.impl;

import com.youbug.mall.product_pms.entity.PmsAttrAttrgroupRelation;
import com.youbug.mall.product_pms.mapper.PmsAttrAttrgroupRelationMapper;
import com.youbug.mall.product_pms.service.IPmsAttrAttrgroupRelationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import com.youbug.common.vo.QueryVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.Collection;

/**
 * <p>
 * 属性&属性分组关联 服务实现类
 * </p>
 *
 * @author youbug
 * @since 2024-04-11
 */
@Service
public class PmsAttrAttrgroupRelationServiceImpl extends ServiceImpl<PmsAttrAttrgroupRelationMapper, PmsAttrAttrgroupRelation> implements IPmsAttrAttrgroupRelationService {

        @Override
        public IPage<PmsAttrAttrgroupRelation> getPmsAttrAttrgroupRelationPage(QueryVo<PmsAttrAttrgroupRelation> queryVo) {

        Page<PmsAttrAttrgroupRelation> paramPage = new Page<>();

        paramPage.setCurrent(queryVo.getCurrentPage());

        paramPage.setSize(queryVo.getPageSize());

        QueryWrapper<PmsAttrAttrgroupRelation> wrapper = new QueryWrapper<>();

        PmsAttrAttrgroupRelation pmsAttrAttrgroupRelation = queryVo.getPayload();

        if(!ObjectUtils.isEmpty(pmsAttrAttrgroupRelation)){
        }
        if(!ObjectUtils.isEmpty(queryVo.getStartTime())){
            wrapper.gt("create_time", queryVo.getStartTime());
        }
        if(!ObjectUtils.isEmpty(queryVo.getEndTime())){
            wrapper.lt("create_time", queryVo.getEndTime());
        }
        wrapper.orderByDesc("create_time");

        Page<PmsAttrAttrgroupRelation> page = this.page(paramPage, wrapper);

        return page;
        }
        @Transactional(transactionManager = "transactionManagerPms", rollbackFor = Exception.class)
        public boolean saveBatch(Collection<PmsAttrAttrgroupRelation> entityList) {
                return saveBatch(entityList, DEFAULT_BATCH_SIZE);
        }
}
